import { Common } from "@/interface/common";
import {  WButton } from "@/components/";

export interface List extends HomeServiceAPI.GetProduct.Res {}

interface HomeColumnProps {
  onView: (v: List, cb: Common.Button.Callback) => void;
}

export const homeColumn = ({ onView }: HomeColumnProps): Common.Columns[] => [
  {
    label: "名称",
    name: "name",
    tableItem: {},
    formItem: {
      input: {
        disabled: true,
      },
    },
  },
  {
    label: "价格",
    name: "price",
    tableItem: {},
    formItem: {
      input: {
        disabled: true,
      },
    },
  },
  {
    label: "商品",
    name: "img",
    tableItem: {
      width: 100,
      // h: [
      //   (v: List) => {
      //     const src = `http://121.36.7.173:3000${v.img}`;
      //     return h(WImage, {
      //       src,
      //       previewSrcList: [src],
      //       style: {
      //         width: "100px",
      //         height: "100px",
      //       },
      //     });
      //   },
      // ],
    },
  },
  {
    label: "操作",
    name: "",
    tableItem: {
      type: "button",
      buttons: [
        {
          name: "查看",
          event: onView,
          type: "primary",
          size: "small",
        },
      ],

      h: [
        (v: List) =>
          h(
            WButton,
            {
              type: "primary",
              size: "small",
              onClick: (cb) => {
                onView(v, cb);
              },
            },
            {
              default: () => "查看",
            }
          ),
      ],
    },
  },
];
